﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TicketTaking.model
{
    public class TicketSetting
    {
        public string Client { get; set; }
        public string Secret { get; set; }
        public string Username { get; set; }
        public string Password { get; set; }
        public string RequestUrl { get; set; }

        public bool IsValid
        {
            get
            {
                return !(string.IsNullOrEmpty(Client) || string.IsNullOrEmpty(Secret) || string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(RequestUrl));
            }
        }

        public static TicketSetting Init()
        {
            return new TicketSetting {
                Client = System.Configuration.ConfigurationSettings.AppSettings["client"],
                Secret = System.Configuration.ConfigurationSettings.AppSettings["secret"],
                Username = System.Configuration.ConfigurationSettings.AppSettings["username"],
                Password = System.Configuration.ConfigurationSettings.AppSettings["password"],
                RequestUrl = System.Configuration.ConfigurationSettings.AppSettings["request_url"],
            };
        }
    }
}
